import {defineConfig} from 'vite'
import vue from '@vitejs/plugin-vue'
import {createSvgIconsPlugin} from "vite-plugin-svg-icons";
import path from 'path';
import {viteMockServe} from "vite-plugin-mock";
// https://vite.dev/config/
export default defineConfig(({command}) => {
    return {
        plugins: [vue(),
            // 引入svg插件
            createSvgIconsPlugin({
                // 指定需要缓存的图标文件夹
                iconDirs: [path.resolve(process.cwd(), 'src/assets/icons')],
                // 指定symbolId格式
                symbolId: 'icon-[dir]-[name]',
            }),
        viteMockServe(
            {
                // 保证加载mock数据
                enable: command === 'serve',
                // 解析根目录下mock文件夹
                mockPath: 'mock',
            }
        )],
        resolve: {
            alias: {
                '@': '/src'
            }
        },
        css: {
            preprocessorOptions: {
                scss: {
                    additionalData: '@use "@/styles/variables.scss" as *;',
                },
            },
        }
    }
})
